package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.Warehouse;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WarehouseDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主id")
    private Integer id;

    @ApiModelProperty(value = "仓库名称")
    private String name;

    @ApiModelProperty(value = "公司id")
    private Integer companyId;

    @ApiModelProperty(value = "仓库负责人")
    private Integer adminId;

    @ApiModelProperty(value = "仓库地址")
    private String address;

    @ApiModelProperty(value = "仓库紧急联系电话")
    private String phone;

    @ApiModelProperty(value = "是否临时：0，是临时仓库，1：永久仓库")
    private Integer isTemporary;

    @ApiModelProperty(value = "是否启用：0禁用，1启用")
    private Integer state;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "是否在盘点：0否 1是")
    private Integer isInventory;

    @ApiModelProperty(value = "仓库负责人名称")
    private String adminName;


    public WarehouseDTO() {}

    public WarehouseDTO(Warehouse entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static WarehouseDTO convert(Warehouse entity) {
        return new WarehouseDTO(entity);
    }

    public static List<WarehouseDTO> convertList(List<Warehouse> list) {
        List<WarehouseDTO> resultList = new ArrayList<>();
        for (Warehouse entity : list) {
            resultList.add(new WarehouseDTO(entity));
        }
        return resultList;
    }}
